/* 8911106 302933981 Ofri Keidar */

/******************************************************************************
* Student Name: Ofri Keidar
* Exercise Name: Ex6
* File Description: Class Sale's interface. A Sale object points at item to
* 					be sold and holds the amount to sale. It also has an Order
* 					pointer, in case an order should be done to balance stock
******************************************************************************/

#ifndef SALE_H_
#define SALE_H_
#include "Item.h"
#include "Order.h"
#include "MyAuto_ptr.h"
#define DEFLT_AMOUNT 0 // default amount value

class Sale {
private:
	int m_amoutToSale; // amount of items sold
	const Item* m_itemSold; // pointer to item sold
	Order* m_balanceStockOrder; // pointer to order in case too many items were sold

public:
	/***************************************************************************************
	* function name: Sale(const int amount = DEFLT_AMOUNT, const Item* itemSold = NULL)
	* The Input: Ordered amount and pointer to item to be sold
	* The output: None
	* The Function operation: Creates a new sale for given item
	***************************************************************************************/
	Sale(const int amount = DEFLT_AMOUNT, const Item* itemSold = NULL);

	/***************************************************************************************
	* function name: Sale(const Sale& saleToCopy)
	* The Input: Sale object to be copied
	* The output: None
	* The Function operation: Creates a new sale with given sale's attributes
	***************************************************************************************/
	Sale(const Sale& saleToCopy);

	/***************************************************************************************
	* function name: ~Sale()
	* The Input: None
	* The output: None
	* The Function operation: Destructs sale object
	***************************************************************************************/
	~Sale();

	/***************************************************************************************
	* function name: void updateOrder(Order& order)
	* The Input: Reference to sale's order
	* The output: None
	* The Function operation: Sets sale's order pointer as given value
	***************************************************************************************/
	void updateOrder(Order& order) {m_balanceStockOrder = &order;}

	/***************************************************************************************
	 * function name: friend ostream& operator << (ostream &os, const Sale& saleToPrint)
	 * The Input: Reference to sale to be printed
	 * The output: ostream reference
	 * The Function operation: Prints sale's details
	 ***************************************************************************************/
	friend ostream& operator << (ostream &os, const Sale& saleToPrint);
};

#endif
